package service

import (
	"context"
	"strconv"

	"admin_template/bff/admin/internal/schema"
	"github.com/cloudwego/hertz/pkg/app"
)

type EnforcerRepo interface {
	Del(roleID int64) error
	UpdateApi(old, new schema.EnforcerInfo) error
	Update(roleID int64, list []schema.EnforcerInfo) error
	Get(roleID int64) ([]schema.EnforcerInfo, error)
	Enforce(sub, obj, act string) error
	Init(ctx context.Context) error
}

func (s *Service) Enforce(ctx *app.RequestContext, path, method string) error {
	return s.EnforcerRepo.Enforce(strconv.Itoa(int(s.RoleID(ctx))), path, method)
}
